/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJFrame.java
 *
 * Created on 2014-3-1, 15:09:35
 */
package com.web.ui;

import com.web.ui.common.component.InternalFrame;
import com.web.ui.common.component.TabButton;
import com.web.ui.common.global.APPParameters;
import java.awt.Color;
import java.awt.Image;
import java.awt.KeyEventPostProcessor;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JViewport;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import org.jdesktop.application.Application;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.jdic.browser.WebBrowser;

/**
 *
 * @author 920web.com
 */
public class UIMain extends FrameView {
    
    String strColorValue = "";
    int cRed;
    int cYellow;
    int cBlue;

    /** Creates new form NewJFrame */
    public UIMain(SingleFrameApplication app) {
        super(app);
        //全局监听
        myKey = new MyKeyEventPostProcessor();
        resourceMap = getResourceMap();
        this.getFrame().setIconImage(new ImageIcon(getClass().getResource(resourceMap.getString("MainFram.Icon"))).getImage());//修改图标
        this.getFrame().setTitle(resourceMap.getString("Frame.title")); //  设置标题
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        toolBar = new javax.swing.JToolBar();
        jbtAccount = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jbtResource = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        jbtApplication = new javax.swing.JButton();
        jSeparator5 = new javax.swing.JToolBar.Separator();
        jbtAuthorizations = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        jbtPolicy = new javax.swing.JButton();
        jSeparator7 = new javax.swing.JToolBar.Separator();
        jbtAudit = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        jbtHelp = new javax.swing.JButton();
        dataPanel = new javax.swing.JPanel();
        tabButtonPanel = new javax.swing.JPanel();
        leftLabel = new javax.swing.JLabel();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        userMsgLabel = new javax.swing.JLabel();
        objNumberLabel = new javax.swing.JLabel();
        styleButtonGroup = new javax.swing.ButtonGroup();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        exitMenuItem = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        mainPanel.setAlignmentY(0.0F);
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(1440, 900));
        mainPanel.setLayout(new java.awt.BorderLayout());

        jPanel1.setName("jPanel1"); // NOI18N

        toolBar.setRollover(true);
        toolBar.setAlignmentX(0.0F);
        toolBar.setEnabled(false);
        toolBar.setMinimumSize(new java.awt.Dimension(430, 40));
        toolBar.setName("toolBar"); // NOI18N
        toolBar.setPreferredSize(new java.awt.Dimension(10, 40));
        toolBar.setRequestFocusEnabled(false);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(UIMain.class);
        jbtAccount.setIcon(resourceMap.getIcon("jbtAccount.icon")); // NOI18N
        jbtAccount.setText(resourceMap.getString("jbtAccount.text")); // NOI18N
        jbtAccount.setToolTipText(resourceMap.getString("jbtAccount.toolTipText")); // NOI18N
        jbtAccount.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtAccount.setMaximumSize(new java.awt.Dimension(100, 35));
        jbtAccount.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtAccount.setName("jbtAccount"); // NOI18N
        jbtAccount.setPreferredSize(new java.awt.Dimension(0, 0));
        jbtAccount.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtAccount.addActionListener(myKey);
        //jbtAccount.registerKeyboardAction(symListener, KeyStroke.getKeyStroke(KeyEvent.VK_F3,0), JComponent.WHEN_IN_FOCUSED_WINDOW);
        toolBar.add(jbtAccount);

        jSeparator3.setName("jSeparator3"); // NOI18N
        toolBar.add(jSeparator3);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(UIMain.class, this);
        jbtResource.setAction(actionMap.get("showSlaveAccount")); // NOI18N
        jbtResource.setIcon(resourceMap.getIcon("jbtResource.icon")); // NOI18N
        jbtResource.setText(resourceMap.getString("jbtResource.text")); // NOI18N
        jbtResource.setToolTipText(resourceMap.getString("jbtResource.toolTipText")); // NOI18N
        jbtResource.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtResource.setMaximumSize(new java.awt.Dimension(110, 32));
        jbtResource.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtResource.setName("jbtResource"); // NOI18N
        jbtResource.setPreferredSize(new java.awt.Dimension(0, 0));
        jbtResource.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtResource.addActionListener(myKey);
        //jbtResource.registerKeyboardAction(symListener, KeyStroke.getKeyStroke(KeyEvent.VK_F4,0), JComponent.WHEN_IN_FOCUSED_WINDOW);
        toolBar.add(jbtResource);

        jSeparator4.setName("jSeparator4"); // NOI18N
        jSeparator4.setPreferredSize(new java.awt.Dimension(8, 4));
        toolBar.add(jSeparator4);

        jbtApplication.setAction(null);
        jbtApplication.setIcon(resourceMap.getIcon("jbtApplication.icon")); // NOI18N
        jbtApplication.setText(resourceMap.getString("jbtApplication.text")); // NOI18N
        jbtApplication.setToolTipText(resourceMap.getString("jbtApplication.toolTipText")); // NOI18N
        jbtApplication.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtApplication.setMaximumSize(new java.awt.Dimension(110, 32));
        jbtApplication.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtApplication.setName("jbtApplication"); // NOI18N
        jbtApplication.setPreferredSize(new java.awt.Dimension(0, 0));
        jbtApplication.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolBar.add(jbtApplication);

        jSeparator5.setName("jSeparator5"); // NOI18N
        jSeparator5.setPreferredSize(new java.awt.Dimension(8, 4));
        toolBar.add(jSeparator5);

        jbtAuthorizations.setAction(null);
        jbtAuthorizations.setIcon(resourceMap.getIcon("jbtAuthorizations.icon")); // NOI18N
        jbtAuthorizations.setText(resourceMap.getString("jbtAuthorizations.text")); // NOI18N
        jbtAuthorizations.setToolTipText(resourceMap.getString("jbtAuthorizations.toolTipText")); // NOI18N
        jbtAuthorizations.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtAuthorizations.setMaximumSize(new java.awt.Dimension(100, 32));
        jbtAuthorizations.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtAuthorizations.setName("jbtAuthorizations"); // NOI18N
        jbtAuthorizations.setPreferredSize(new java.awt.Dimension(65, 45));
        jbtAuthorizations.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtAuthorizations.addActionListener(myKey);
        //jbtAuthorizations.registerKeyboardAction(symListener, KeyStroke.getKeyStroke(KeyEvent.VK_F6,0), JComponent.WHEN_FOCUSED);
        toolBar.add(jbtAuthorizations);

        jSeparator6.setName("jSeparator6"); // NOI18N
        jSeparator6.setPreferredSize(new java.awt.Dimension(8, 4));
        toolBar.add(jSeparator6);

        jbtPolicy.setIcon(resourceMap.getIcon("jbtPolicy.icon")); // NOI18N
        jbtPolicy.setText(resourceMap.getString("jbtPolicy.text")); // NOI18N
        jbtPolicy.setToolTipText(resourceMap.getString("jbtPolicy.toolTipText")); // NOI18N
        jbtPolicy.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtPolicy.setMaximumSize(new java.awt.Dimension(100, 32));
        jbtPolicy.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtPolicy.setName("jbtPolicy"); // NOI18N
        jbtPolicy.setPreferredSize(new java.awt.Dimension(65, 45));
        jbtPolicy.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtPolicy.addActionListener(myKey);
        //jbtPolicy.registerKeyboardAction(symListener, KeyStroke.getKeyStroke(KeyEvent.VK_F7,0), JComponent.WHEN_IN_FOCUSED_WINDOW);
        toolBar.add(jbtPolicy);

        jSeparator7.setName("jSeparator7"); // NOI18N
        jSeparator7.setPreferredSize(new java.awt.Dimension(8, 4));
        toolBar.add(jSeparator7);

        jbtAudit.setIcon(resourceMap.getIcon("jbtAudit.icon")); // NOI18N
        jbtAudit.setText(resourceMap.getString("jbtAudit.text")); // NOI18N
        jbtAudit.setToolTipText(resourceMap.getString("jbtAudit.toolTipText")); // NOI18N
        jbtAudit.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtAudit.setMaximumSize(new java.awt.Dimension(100, 32));
        jbtAudit.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtAudit.setName("jbtAudit"); // NOI18N
        jbtAudit.setPreferredSize(new java.awt.Dimension(65, 45));
        jbtAudit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtAudit.addActionListener(myKey);
        //jbtAudit.registerKeyboardAction(symListener, KeyStroke.getKeyStroke(KeyEvent.VK_F8,0), JComponent.WHEN_IN_FOCUSED_WINDOW);
        toolBar.add(jbtAudit);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jSeparator1.setPreferredSize(new java.awt.Dimension(8, 4));
        toolBar.add(jSeparator1);

        jbtHelp.setIcon(resourceMap.getIcon("jbtHelp.icon")); // NOI18N
        jbtHelp.setText(resourceMap.getString("jbtHelp.text")); // NOI18N
        jbtHelp.setToolTipText(resourceMap.getString("jbtHelp.toolTipText")); // NOI18N
        jbtHelp.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtHelp.setMaximumSize(new java.awt.Dimension(70, 29));
        jbtHelp.setMinimumSize(new java.awt.Dimension(60, 29));
        jbtHelp.setName("jbtHelp"); // NOI18N
        jbtHelp.setPreferredSize(new java.awt.Dimension(65, 45));
        jbtHelp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtHelp.addActionListener(myKey);
        //jbtHelp.registerKeyboardAction(symListener, KeyStroke.getKeyStroke(KeyEvent.VK_F1,0), JComponent.WHEN_IN_FOCUSED_WINDOW);
        jbtHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtHelpActionPerformed(evt);
            }
        });
        toolBar.add(jbtHelp);

        dataPanel.setName("dataPanel"); // NOI18N
        dataPanel.setLayout(new java.awt.BorderLayout());

        tabButtonPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        tabButtonPanel.setAlignmentX(0.0F);
        tabButtonPanel.setAlignmentY(0.0F);
        tabButtonPanel.setName("tabButtonPanel"); // NOI18N
        tabButtonPanel.setPreferredSize(new java.awt.Dimension(1502, 22));
        tabButtonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));

        leftLabel.setName("leftLabel"); // NOI18N
        leftLabel.setPreferredSize(new java.awt.Dimension(3, 20));
        tabButtonPanel.add(leftLabel);

        dataPanel.add(tabButtonPanel, java.awt.BorderLayout.PAGE_START);

        jDesktopPane1.setName("jDesktopPane1"); // NOI18N
        dataPanel.add(jDesktopPane1, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(toolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 773, Short.MAX_VALUE)
            .addComponent(dataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 773, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE))
        );

        mainPanel.add(jPanel1, java.awt.BorderLayout.CENTER);

        statusPanel.setName("statusPanel"); // NOI18N
        statusPanel.setPreferredSize(new java.awt.Dimension(0, 30));

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        userMsgLabel.setName("userMsgLabel"); // NOI18N

        objNumberLabel.setVisible(false);
        objNumberLabel.setName("objNumberLabel"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 773, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(statusMessageLabel)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                        .addComponent(userMsgLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 464, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(objNumberLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 753, Short.MAX_VALUE)
                        .addComponent(statusAnimationLabel)))
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel))
                        .addGap(12, 12, 12))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                        .addComponent(userMsgLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(objNumberLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(progressBar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N
        menuBar.add(jMenu2);

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

private void jbtHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtHelpActionPerformed

}//GEN-LAST:event_jbtHelpActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel dataPanel;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    public static javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JToolBar.Separator jSeparator7;
    private javax.swing.JButton jbtAccount;
    private javax.swing.JButton jbtApplication;
    private javax.swing.JButton jbtAudit;
    private javax.swing.JButton jbtAuthorizations;
    private javax.swing.JButton jbtHelp;
    private javax.swing.JButton jbtPolicy;
    private javax.swing.JButton jbtResource;
    private javax.swing.JLabel leftLabel;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JLabel objNumberLabel;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.ButtonGroup styleButtonGroup;
    private javax.swing.JPanel tabButtonPanel;
    private javax.swing.JToolBar toolBar;
    private javax.swing.JLabel userMsgLabel;
    // End of variables declaration//GEN-END:variables
    //全局监听
    private MyKeyEventPostProcessor myKey;
    private ResourceMap resourceMap;
    //在激活链表中将该Tab对应的窗口移动到第一个
    private TabButton tabButtonClick;
    // 按钮Iterator
    private Iterator buttonIterator;
    // 按钮sequnce
    private int sequnce = 0;
    // 按钮
    private TabButton tabButtonSequnce = null;

    // tabButtonPanel中有没有活动按钮标识
    private boolean activeFlag = false;
    
    
    
    
        /**
     * 接收键盘事件，实现全局健盘监听
     *
     * @author   于采兴
     * @version  Ver 1.0 2009-6-22 新建
     * @since    PASIAM Ver 1.0
     */
    class MyKeyEventPostProcessor implements KeyEventPostProcessor, ActionListener {

        //org.jdesktop.application.ResourceMap resourceMap = Application.getInstance(PASIAMApp.class).getContext().getResourceMap(MainFrame.class);
        public boolean postProcessKeyEvent(KeyEvent e) {

            //如果不是按下alt 组合健
            if (!e.isAltDown()) {

                if (e.getKeyCode() == KeyEvent.VK_F2 && jbtAccount.isEnabled()) {//用户模块
                    //createInnerFrame(resourceMap.getString("frameButton.Account"));
                    System.out.println("22222222222222");

                }
                //else if (e.getKeyCode() == KeyEvent.VK_F3 && jbtResource.isEnabled()) {//资源模块
//                    createInnerFrame(resourceMap.getString("frameButton.Resource"));
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F4 && jbtApplication.isEnabled()) {//应用模块
//                    createInnerFrame(resourceMap.getString("frameButton.Application"));
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F5 && jbtAuthorizations.isEnabled()) {//授权模块
//                    createInnerFrame(resourceMap.getString("frameButton.Authorizations"));
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F6 && jbtPolicy.isEnabled()) {//策略模块
//                    createInnerFrame(resourceMap.getString("frameButton.Policy"));
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F7 && jbtAudit.isEnabled()) {//审计模块
//                    createInnerFrame(resourceMap.getString("frameButton.Audit"));
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F1 && jbtHelp.isEnabled()) {//帮助模块
//                    //createInnerFrame("resourceMap.getString("frameButton.Help")");
//                } else if (e.getKeyCode() == KeyEvent.VK_F8) {//打开个人信息维护窗口
//                    selfInfoModify();
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F9) {//打开更改密码窗口
//                    selfPasswordModify();
//
//                } else if (e.getKeyCode() == KeyEvent.VK_F12) {//打开系统锁定窗口
//                    sysLock();
//
//                }
            }
            return true;
        }

        public void actionPerformed(ActionEvent evt) {
            Object obj = evt.getSource();
            if (obj == jbtAccount) {//用户按钮的响应处理等
                createInnerFrame(resourceMap.getString("frameButton.Account"));
System.out.println("3333333333333333");
            } 
//else if (obj == jbtResource) {//资源按钮的响应处理等
//                createInnerFrame(resourceMap.getString("frameButton.Resource"));
//
//            } else if (obj == jbtApplication) {//应用按钮的响应处理等
//                createInnerFrame(resourceMap.getString("frameButton.Application"));
//
//            } else if (obj == jbtAuthorizations) {//授权按钮的响应处理等
//                createInnerFrame(resourceMap.getString("frameButton.Authorizations"));
//
//            } else if (obj == jbtPolicy) {//策略按钮的响应处理等
//                createInnerFrame(resourceMap.getString("frameButton.Policy"));
//
//            } else if (obj == jbtAudit) {//审计按钮的响应处理等
//                createInnerFrame(resourceMap.getString("frameButton.Audit"));
//
//            } else if (obj == jbtHelp) {//帮助按钮的响应处理等
//                //createInnerFrame("resourceMap.getString("frameButton.Help")");
//            }
        }
    }
        /**
     * 创建内部窗口对象
     * <p>

     * @param title 窗口的标题
     * @return void
     * @author 刘红军
     * @since 1.0
     */
    private void createInnerFrame(String title) {
System.out.println("--createInnerFrame--"+title);
        try {
            //  循环所有的tabButton，将他们置为false
            TabButton tabButtonTemp;
            for (Integer i : APPParameters.getInnerFrameTabButtons().keySet()) {
                tabButtonTemp = APPParameters.getInnerFrameTabButtons().get(i);
                if (InternalFrame.isOpenHost && tabButtonTemp.getTitle().equals(resourceMap.getString("frameButton.Audit"))) {
                    JViewport viewPort = APPParameters.getInnerFrames().get(i).getRightScrollPanel().getViewport();
                    if (1 <= viewPort.getComponentCount() && viewPort.getComponent(0) instanceof WebBrowser) {
                        viewPort.remove(InternalFrame.webBrowser);
                        if (InternalFrame.webBrowser != null) {
                            //InternalFrame.webBrowser.setURL(new URL(PasiamConstants.BASTIONHOST_EXIT_HTML));
                            InternalFrame.webBrowser = null;
                        //InternalFrame.isOpenHost = false;
                        }
                    }
                }
                tabButtonTemp.setActive(false);
            }

            //  如果要新建的tabButton已经存在，将该tab和对应的internalFrame显示出来
            for (Integer i : APPParameters.getInnerFrameTabButtons().keySet()) {
                tabButtonTemp = APPParameters.getInnerFrameTabButtons().get(i);
                if (tabButtonTemp.getTitle().equals(title)) {
                    tabButtonTemp.setActive(true);
                    InternalFrame internalFrame = APPParameters.getInnerFrames().get(i);
                    internalFrame.setSelected(true);
                    internalFrame.setVisible(true);

                    //最大化窗口
                    internalFrame.setMaximum(true);

                    //隐藏标题栏
                    ((BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null);
                    internalFrame.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
                    //  去掉边框
                    internalFrame.setBorder(BorderFactory.createEmptyBorder());
                    UIMain.setTalButtonsColor();
                    return;
                }
            }


            //获得一个新的窗口索引
            int newSequenceValue = APPParameters.nextInnerFrameSequence();

            //创建一个内部窗口
            InternalFrame internalFrame = new InternalFrame(newSequenceValue, title);

            // 如果已经有了新的样式，就采用新的样式
            if (!"".equals(strColorValue)) {
                internalFrame.getRightScrollPanel().setBackground(new Color(cRed, cYellow, cBlue));
                internalFrame.getRightScrollPanel().getComponent(0).setBackground(new Color(cRed, cYellow, cBlue));
            }

            //将窗口放入容器中
            getDesktopPane1().add(internalFrame);

            //设置内部窗口的属性
            internalFrame.setSelected(true);
            internalFrame.setVisible(true);

            //最大化窗口
            internalFrame.setMaximum(true);

            //隐藏标题栏
            ((BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null);
            internalFrame.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
            //  去掉边框
            internalFrame.setBorder(BorderFactory.createEmptyBorder());

            //创建一个Tab按钮对象
            createTabButton(newSequenceValue, title);

            //将内部窗口对象放入集合中
            APPParameters.getInnerFrames().put(newSequenceValue, internalFrame);

        } catch (Exception ex) {
            //System.out.println(ex.getStackTrace());
            //Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public static javax.swing.JDesktopPane getDesktopPane1() {
        return jDesktopPane1;
    }
        /**
     * 设置所有TabButton的颜色
     * <p>
     * 软件同一时刻只有一个TabButton是选中的，这个TabButton的颜色是高亮显示的，其余的应该是暗色
     * 当某个TabButton被创建、单击或者某个内部窗口被关闭都应该重新设置所有TabButton的颜色
     *
     * @return void
     * @author 刘红军、李林
     * @since 1.0
     */
    public static void setTalButtonsColor() {

        ResourceMap resourceMap = Application.getInstance(UIApp.class).getContext().getResourceMap(UIMain.class);

        // 取得按钮组
        Iterator buttonIterator = APPParameters.getInnerFrameTabButtons().keySet().iterator();
        // 按钮sequnce
        int sequnce = 0;
        // 按钮
        TabButton tabButtonSequnce = null;

        // 循环按钮组，查看有没有活动按钮
        while (buttonIterator.hasNext()) {

            sequnce = ((Integer) buttonIterator.next()).intValue();
            tabButtonSequnce = APPParameters.getInnerFrameTabButtons().get(sequnce);

            if (tabButtonSequnce != null) {
                // 如果是活动窗口
                if (tabButtonSequnce.getActive()) {

                    Image bt2 = ((ImageIcon) resourceMap.getIcon("bt_bg2.icon")).getImage();
                    Image btcoles2 = ((ImageIcon) resourceMap.getIcon("bt_bg2_close.icon")).getImage();
                    tabButtonSequnce.getGraphics().drawImage(bt2, 0, 0, tabButtonSequnce.getWidth(), tabButtonSequnce.getHeight(), tabButtonSequnce);
                    tabButtonSequnce.getGraphics().drawImage(btcoles2, 120, 5, btcoles2.getWidth(tabButtonSequnce), btcoles2.getHeight(tabButtonSequnce), tabButtonSequnce);
                    tabButtonSequnce.getGraphics().setColor(Color.white);
                    tabButtonSequnce.getGraphics().drawString(tabButtonSequnce.getTitle(), 5, 15);
                    tabButtonSequnce.update(tabButtonSequnce.getGraphics());

                // 如果不是活动窗口
                } else {

                    Image bt1 = ((ImageIcon) resourceMap.getIcon("bt_bg1.icon")).getImage();
                    Image btcoles1 = ((ImageIcon) resourceMap.getIcon("bt_bg1_close.icon")).getImage();

                    tabButtonSequnce.getGraphics().drawImage(bt1, 0, 0, tabButtonSequnce.getWidth(), tabButtonSequnce.getHeight(), tabButtonSequnce);
                    tabButtonSequnce.getGraphics().drawImage(btcoles1, 120, 5, btcoles1.getWidth(tabButtonSequnce), btcoles1.getHeight(tabButtonSequnce), tabButtonSequnce);
                    tabButtonSequnce.getGraphics().drawString(tabButtonSequnce.getTitle(), 5, 15);
                }
            }
        }
    }
    /**
     * 创建一个Tab按钮对象
     * <p>
     *
     * @param newSequenceValue 按钮的名称
     * @param title 按钮的文字
     * @return void
     * @author 刘红军、李林
     * @since 1.0
     */
    private void createTabButton(final int newSequenceValue, String title) {
        try {

            //创建一个Tab按钮
            TabButton tabButton = new TabButton(title);
            tabButton.setSize(150, 18);
            tabButton.setName("" + newSequenceValue);
            //tabButton.getJbtClose().setName("" + newSequenceValue);
            tabButton.setActive(true);

            APPParameters.getInnerFrameTabButtons().put(newSequenceValue, tabButton);

            //设置Tab按钮的事件
            tabButton.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    pressSelf(e);
                }

                public void mousePressed(MouseEvent e) {
                    // pressSelf(e);
                }

                public void pressSelf(MouseEvent evt) {

                    //在激活链表中将该Tab对应的窗口移动到第一个
                    tabButtonClick = ((TabButton) evt.getComponent());

                    // 取得按钮范围
                    Rectangle Bounds = tabButtonClick.getVisibleRect().getBounds();
                    Rectangle rectClose = new Rectangle();
                    // 取得关闭按钮范围
                    rectClose.setBounds(((Double) (Bounds.getX() + 120)).intValue(), ((Double) (Bounds.getY())).intValue(), ((Double) (Bounds.getWidth() - 120)).intValue(), ((Double) (Bounds.getHeight())).intValue());

                    if (rectClose.contains(evt.getPoint())) {

                        // 如果点击的是在关闭按钮范围
                        closeInTabWindow();

                    } else {
                        // 如果点击的是在关闭按钮范围之外
                        closeOutTabWindow(evt);

                    }

                }
            });

            //将Tab按钮加到集合
            tabButtonPanel.add(tabButton);

            tabButton.setActive(true);
            //改变Tab按钮的颜色
            UIMain.setTalButtonsColor();

        } catch (Exception ex) {
            //Logger.getLogger(InternalFrame.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();
        }
    }
    /**
     * 关闭当前使用的标签页<br>
     * 如果点击的是在关闭按钮范围
     *
     * @author   于采兴
     * @version  Ver 1.0 2009-6-22 新建
     * @since    PASIAM Ver 1.0
     */
    private void closeInTabWindow() {

        try {
            // 取得按钮组
            buttonIterator = APPParameters.getInnerFrameTabButtons().keySet().iterator();
            // 循环按钮组，查看有没有活动按钮
            while (buttonIterator.hasNext()) {

                sequnce = ((Integer) buttonIterator.next()).intValue();
                tabButtonSequnce = APPParameters.getInnerFrameTabButtons().get(sequnce);

                // 如果是选中窗口
                if (tabButtonSequnce.equals(tabButtonClick)) {

                    // 如果是活动窗口
                    if (tabButtonClick.getActive()) {

                        // 把tabButtonPanel中“有没有活动按钮标识”设为true.
                        activeFlag = true;
                    }

                    if (tabButtonClick.getTitle().equals(resourceMap.getString("frameButton.Audit"))) {

                        if (InternalFrame.webBrowser != null) {

                            try {
                                //InternalFrame.webBrowser.setURL(new URL(PasiamConstants.BASTIONHOST_EXIT_HTML));
                                InternalFrame.webBrowser = null;
                            } catch (Exception ex) {
                                //Logger.getLogger(UIMain.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            InternalFrame.isOpenHost = false;
                            //从按钮Iterator中删除
                            buttonIterator.remove();
                            //删除对应的Tab按钮
                            tabButtonPanel.remove(tabButtonSequnce);

                        } else {
                            // 从按钮Iterator中删除
                            buttonIterator.remove();
                            //删除对应的Tab按钮
                            tabButtonPanel.remove(tabButtonSequnce);
                        }

                    } else {
                        // 从按钮Iterator中删除
                        buttonIterator.remove();
                        //删除对应的Tab按钮
                        tabButtonPanel.remove(tabButtonSequnce);
                    }

                    tabButtonPanel.updateUI();

                    //删除在集合中对应的Tab按钮、内部窗口
                    APPParameters.getInnerFrameTabButtons().remove(sequnce);
                    //关闭窗口
                    APPParameters.getInnerFrames().get(sequnce).dispose();
                    APPParameters.getInnerFrames().remove(sequnce);
                }
            }

            // 如果关闭的不是活动窗口，就把最后的按钮设为活动按钮
            if (activeFlag) {
                // 取得按钮Key组
                Object[] keyArray = APPParameters.getInnerFrameTabButtons().keySet().toArray();

                if (keyArray.length != 0) {

                    // 取得最后一个按钮
                    tabButtonSequnce = APPParameters.getInnerFrameTabButtons().get(((Integer) (keyArray[keyArray.length - 1])).intValue());

                    // 把按钮设为活动按钮
                    tabButtonSequnce.setActive(true);

                    //将当前tab按钮对应的窗口设为活动窗口
                    APPParameters.getInnerFrames().get(((Integer) (keyArray[keyArray.length - 1])).intValue()).setSelected(true);
                }
            }

            //改变Tab按钮的颜色
            UIMain.setTalButtonsColor();
        } catch (PropertyVetoException ex) {
           // Logger.getLogger(InternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 /**
     * 关闭鼠标所点击的标签页<br>
     * 如果点击的是在关闭按钮范围之外
     *
     * @param    evt 
     * @author   于采兴、李林
     * @version  Ver 1.0 2009-6-22 新建
     * @since    PASIAM Ver 1.0
     */
    private void closeOutTabWindow(MouseEvent evt) {

        try {

            // 取得按钮组
            buttonIterator = APPParameters.getInnerFrameTabButtons().keySet().iterator();

            while (buttonIterator.hasNext()) {
                sequnce = ((Integer) buttonIterator.next()).intValue();
                tabButtonSequnce = APPParameters.getInnerFrameTabButtons().get(sequnce);

                //将当前tab按钮对应的窗口设为活动窗口
                InternalFrame internalFrame = APPParameters.getInnerFrames().get(((Integer) sequnce).intValue());
                if (InternalFrame.isOpenHost && tabButtonSequnce.getTitle().equals(resourceMap.getString("frameButton.Audit"))) {

                    if (!tabButtonSequnce.getActive()) {
                        JViewport viewPort = internalFrame.getRightScrollPanel().getViewport();
                        if (1 <= viewPort.getComponentCount() && viewPort.getComponent(0) instanceof WebBrowser) {

                            if (InternalFrame.webBrowser != null) {
                                viewPort.remove(InternalFrame.webBrowser);
                                try {
                                    //InternalFrame.webBrowser.setURL(new URL(PasiamConstants.BASTIONHOST_EXIT_HTML));
                                } catch (Exception ex) {
                                    //Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
                                }
                                InternalFrame.webBrowser = null;
                            // InternalFrame.isOpenHost = false;
                            }
                        }

                    }
                    break;
                }
            }

            buttonIterator = APPParameters.getInnerFrameTabButtons().keySet().iterator();

            // 循环按钮组，把选中的按钮设为活动按钮
            while (buttonIterator.hasNext()) {

                sequnce = ((Integer) buttonIterator.next()).intValue();
                tabButtonSequnce = APPParameters.getInnerFrameTabButtons().get(sequnce);

                // 如果不是选中按钮
                if (!tabButtonSequnce.getTitle().equals(tabButtonClick.getTitle())) {
                    tabButtonSequnce.setActive(false);
                // 如果是选中的按钮
                } else if (tabButtonSequnce.getTitle().equals(tabButtonClick.getTitle())) {


                    //将当前tab按钮对应的窗口设为活动窗口
                    InternalFrame internalFrame = APPParameters.getInnerFrames().get(((Integer) sequnce).intValue());

                    internalFrame.setSelected(true);
                    //最大化窗口
                    internalFrame.setMaximum(true);
                    if (InternalFrame.isOpenHost && tabButtonSequnce.getTitle().equals(resourceMap.getString("frameButton.Audit"))) {

                        if (!tabButtonSequnce.getActive()) {
                            if (((JViewport) internalFrame.getRightScrollPanel().getViewport()).getComponentCount() == 0) {
                                InternalFrame.webBrowser = new WebBrowser();
                                //InternalFrame.webBrowser.setContent(PasiamConstants.BASTIONHOST_LOGIN_HTML);
                                APPParameters.getCurrentInnerFrame().getRightScrollPanel().setViewportView(InternalFrame.webBrowser);
                                internalFrame.getRightScrollPanel().repaint();
                            }
                        }

                    }
                    tabButtonSequnce.setActive(true);
                    //隐藏标题栏
                    ((BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null);
                    //  去掉边框
                    internalFrame.setBorder(BorderFactory.createEmptyBorder());

                    internalFrame.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);

                }
            }

            //改变Tab按钮的颜色
            UIMain.setTalButtonsColor();

            if (evt.getButton() == MouseEvent.BUTTON3) {//如果是右键单击，则弹出菜单
                //MainFramePopMenu popMenu = new MainFramePopMenu(APPParameters.getInnerFrameTabButtons().keySet().iterator(), tabButtonClick, tabButtonPanel);
                //((TabButton) evt.getSource()).setComponentPopupMenu(popMenu);
            }

        /*
        // Tab按钮改变后，刷新树，并按原来的样式展开树
        JTree newTree = null;
        DefaultMutableTreeNode newTreeRoot = null;
        String moduleName = "";
        try {
        //帐号管理类型的树
        if ("资源帐号管理".equals(((TabButton)evt.getSource()).getTitle())) {//帐号管理类型的树
        newTree = new AccountManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.RESOURCE_MODULE;
        }else if ("用户管理".equals(((TabButton)evt.getSource()).getTitle())) {//用户管理类型的树
        newTree = new UserManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.USER_MODULE;
        } else if ("授权管理".equals(((TabButton)evt.getSource()).getTitle())) {//授权管理类型的树
        newTree = new AuthorizationManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.AUTHORIZATION_MODULE;
        } else if ("应用管理".equals(((TabButton)evt.getSource()).getTitle())) {//应用管理类型的树
        newTree = new AppManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.APP_MODULE;
        } else if ("认证管理".equals(((TabButton)evt.getSource()).getTitle())) {//认证管理类型的树
        newTree = new AuthenticateManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.AUTHENTICATE_MODULE;
        } else if ("策略管理".equals(((TabButton)evt.getSource()).getTitle())) {//策略管理类型的树
        newTree = new PolicyManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.POLICY_MODULE;
        } else if ("审计管理".equals(((TabButton)evt.getSource()).getTitle())) {//审计查询类型的树
        newTree = new AuditManageTree().getTree(APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1(), APPParameters.getCurrentInnerFrame().getRightScrollPanel());

        moduleName = PasiamConstants.AUDIT_MODULE;
        }

        // 按原来的样式展开树
        newTreeRoot = (DefaultMutableTreeNode)newTree.getModel().getRoot();
        expandNode(APPParameters.getCurrentInnerFrame().getLeftTree(), newTree, new TreePath(newTreeRoot), moduleName, APPParameters.getCurrentInnerFrame().getRightScrollPanel());
        } catch (InstantiationException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }

        // 刷新树
        APPParameters.getCurrentInnerFrame().getLeftTreeScrollPane1().setViewportView(newTree);
         */
        } catch (PropertyVetoException ex) {
           // Logger.getLogger(InternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
    
    
}
